<?php
require_once("init.php");
require_once("inc/header.php");

$screen_name=$_GET['screen_name'];
$url="http://twitter.com/users/".$screen_name.".json";
$info=obj_to_array(get_from_twitter($url));
?>
        <div class="info_body">
            <div class="user_profile_head">
                <img src="<?php echo get_profile_bigger_image($info["profile_image_url"])?>" alt="" />
            </div>
            <div style="position:relative;float:left;">
                <p style="font-size:13pt;font-weight:bold;"><?=$info["screen_name"]?></p>
                <p>
                    <?php
                    if($screen_name==USER) {
                        echo "<a href='set_option.php'>Set Option</a>";
                    } else {
                        echo "<a href='follow.php?type=create&screen_name=".$screen_name."'>follow</a>&nbsp;&nbsp;";
                        echo "<a href='follow.php?type=destroy&screen_name=".$screen_name."'>unfollow</a>&nbsp;&nbsp;";
                        echo "<a href='inbox.php?screen_name=".$screen_name."'>Direct Message</a>&nbsp;&nbsp;";
                        echo "<a href='set_rating.php?screen_name=".$screen_name."'>Set Rating</a>";
                    }
                    ?>
                </p>
            </div>
            <div class="user_info_detail" style="color: #<?=$info["profile_text_color"]?>;">
                <p>Location:<?=$info["location"]?></p>
                <p>Description:<?=$info["description"]?></p>
                <p>Name:<?=$info["name"]?></p>
                <p>Followers count:<?=$info["followers_count"]?></p>
                <p>Friends count:<?=$info["friends_count"]?></p>
                <p>Favourites count:<?=$info["favourites_count"]?></p>
                <p>Statuses count:<?=$info["statuses_count"]?></p>
                <p>Web:<a href="<?=$info["url"]?>"><?=$info["url"]?></a></p>
            </div>
            <div id="tweets">
                <?php
                $page=$_GET['page'];
                if(!intval($page)>0) {
                    $page=1;
                }
                $url="http://twitter.com/statuses/user_timeline/".$screen_name.".json?page=".$page;
                $timeline=obj_to_array(get_from_twitter($url));
                $i=0;
                $tweets_cache = get_tweets_from_cache();
                foreach($timeline as $msg) {
                    $i+=1;
                    show_msg($i,$msg,$type,$page,$tweets_cache);
                }
                if($page>1) {
                    echo "<a href='user.php?screen_name=".$screen_name."&type=".$type."&page=".($page-1)."'>prev</a> ";
                }
                echo "<a href='user.php?screen_name=".$screen_name."&type=".$type."&page=".($page+1)."'>next</a> ";
                ?>
            </div>
        </div>
<?php
require_once("inc/footer.php");
?>